package com.twsjw.action;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.hibernate.Session;

import com.opensymphony.xwork2.ActionContext;
import com.twsjw.dao.houseDAOImpl;
import com.twsjw.util.HibernateSessionFactory;

public class mainAction {
	String qxid;
	String jdid;
	String low;
	String high;
	String room;
	String hall;
	
	public String getmain(){
		
		String hql="from Houseinfo where 1=1";
		if(qxid!=null&&!qxid.equals("0")){
			hql=hql+" and district_id="+qxid;
		}
		if(jdid!=null&&!jdid.equals("0")){
			hql=hql+" and street_id="+jdid;
		}
		if(low!=null&&!low.equals("0")){
			hql=hql+" and price>"+low;
		}
		if(high!=null&&!high.equals("0")){
			hql=hql+" and price<="+high;
		}
		if(room!=null&&!room.equals("0")){
			hql=hql+" and room="+room;
		}
		if(hall!=null&&!hall.equals("0")){
			hql=hql+" and hall="+hall;
		}
		System.out.println(hql);
		return hql;
		
	}

	
	public String execute()
	{	
		houseDAOImpl h=new houseDAOImpl();
		List l=h.HQL(this.getmain());
		ActionContext act=ActionContext.getContext();
		act.put("hinfo",l);
		return "success";
	}
	
	
	public String getQxid() {
		return qxid;
	}

	public void setQxid(String qxid) {
		this.qxid = qxid;
	}

	public String getJdid() {
		return jdid;
	}

	public void setJdid(String jdid) {
		this.jdid = jdid;
	}

	public String getLow() {
		return low;
	}

	public void setLow(String low) {
		this.low = low;
	}

	public String getHigh() {
		return high;
	}

	public void setHigh(String high) {
		this.high = high;
	}

	public String getRoom() {
		return room;
	}

	public void setRoom(String room) {
		this.room = room;
	}

	public String getHall() {
		return hall;
	}

	public void setHall(String hall) {
		this.hall = hall;
	}
}
